package com.iyjhsoc.game.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.iyjhsoc.game.dao.GameRoleDAO;
import com.iyjhsoc.game.domain.VO.GameRoleVO;
import com.iyjhsoc.game.domain.entity.GameRoleDO;
import com.iyjhsoc.game.domain.response.Response;
import com.iyjhsoc.game.service.GameRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("iyj/game/role")
public class GameRoleController {

    @Autowired
    GameRoleService gameRoleService;


    @PostMapping("save")
    public Response save(@RequestBody GameRoleDO gameRoleDO){
        Response response = gameRoleService.saveGameRole(gameRoleDO);
        return response;
    }

    @GetMapping("queryList")
    public Response queryList(GameRoleVO gameRoleVO){
        Response response = gameRoleService.queryList(gameRoleVO);
        return response;
    }

    @GetMapping("getById")
    public Response getById(String id) {
        GameRoleDO byId = gameRoleService.getById(id);
        return Response.SUCCESS(byId);
    }

    @PostMapping("updateById")
    public Response updateById(@RequestBody GameRoleDO gameRoleDO){
        boolean b = gameRoleService.updateById(gameRoleDO);
        if(b){
            return Response.SUCCESS("修改成功");
        } else {
            return Response.ERROR("修改失败");
        }
    }

}
